//
//  CKTabBarViewController.m
//  ComicKuaiKan
//
//  Created by xin on 2017/8/16.
//  Copyright © 2017年 zwei. All rights reserved.
//

#import "CKTabBarViewController.h"
#import "CKAccountViewController.h"
#import "CKRecommendViewController.h"
#import "CKSearchViewController.h"
#import "CKFavorViewController.h"


@interface CKTabBarViewController ()

@end

@implementation CKTabBarViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    NSMutableArray * controllerArray = [NSMutableArray array];
    NSArray * controllerClassNameArray =
  @[@"CKAccountViewController",
    @"CKRecommendViewController",
    @"CKSearchViewController",
    @"CKFavorViewController"];
    
    [controllerClassNameArray enumerateObjectsUsingBlock:^(id  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
        UIViewController * controller = [NSClassFromString(controllerClassNameArray[idx]) new];
        controller.view.backgroundColor = [UIColor whiteColor];
        UINavigationController * navigationController = [[UINavigationController alloc] initWithRootViewController:controller];
        [controllerArray addObject:navigationController];
    }];
    
    self.viewControllers = controllerArray;
    
    NSArray *images = @[@"favor", @"recommend", @"search", @"account"];
    
    [self.tabBar.items enumerateObjectsUsingBlock:^(UITabBarItem * _Nonnull item, NSUInteger idx, BOOL * _Nonnull stop) {
        item.image = [[UIImage imageNamed:images[idx]] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
        item.selectedImage = [[UIImage imageNamed:[images[idx] stringByAppendingString:@"_hl"]] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
        item.imageInsets = UIEdgeInsetsMake(6, 0, -6, 0);
    }];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
